var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.ObjectId;

mongoose.connect('mongodb://localhost/dar');

var DepartamentoSchema = new Schema({
    nome: {type: String, required: true}
});
this.Departamento = mongoose.model('Departamento', DepartamentoSchema);

var ProfessorSchema = new Schema({
    nome: {type: String, required: true},
    departamento: {type: ObjectId, required: true}
});
this.Professor = mongoose.model('Professor', ProfessorSchema);

var CursoSchema = new Schema({
    nome: {type: String, required: true},
    departamento: {type: ObjectId, required: true},
    pos: {type: Boolean, required: true}
});
this.Curso = mongoose.model('Curso', CursoSchema);

var AlunoSchema = new Schema({
    nome: {type: String, required: true},
    curso: {type: ObjectId, required: true},
    creditosEmObrigatorias: {type: Number, min: 0, default: 0},
    creditosEmEletivas: {type: Number, min: 0, default: 0},
    disciplinasCursadas: {type: [ObjectId], default: []},
    disciplinasAtuais: {type: [ObjectId], default: []}
});
this.Aluno = mongoose.model('Aluno', AlunoSchema);

var DisciplinaSchema = new Schema({
    nome: {type: String, required: true},
    creditosFornecidos: {type: Number, required: true},
    creditosNecessarios: {type: Number, required: true},
    curso: {type: ObjectId, required: true},
    professor: {type: ObjectId, required: true},
    obrigatoria: {type: Boolean, required: true},
    disciplinasNecessarias: {type: [ObjectId], default: []}
});
this.Disciplina = mongoose.model('Disciplina', DisciplinaSchema);
